package com.ftg.learn.lesson6.exam01;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * 学习一下字典
 * <p>
 * 映射 搜索关键 词
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/6/30 上午9:46
 */
public class Directory implements DirectoryMethod {

    private Entry[] words = new Entry[2];

    public Directory() {
        words[0] = new Entry("中国", "中国是一个传大的国度", "china", "china is best!!");
        Entry se = new Entry();
        se.setChina("日本");
        se.setChinaDesc("这是中国的日本省");

        se.setEnglish("Japan");
        se.setEnglishDesc("japan is very must bad");
        words[1] = se;
    }

    @Override
    public String findEntry(String key) {
        for (int i = 0; i < words.length; i ++) {
            if (words[i].getChina().equals(key)) {
                return words[i].getEnglish();
            }
        }
        return "当前没有收录";
    }

    public static void main(String[] args) {
        Directory directory = new Directory();
        System.out.println(directory.findEntry("小日本"));
    }

}
